home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4254 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
  2. From: Dan Pop <danpop@mail.cern.ch>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: simple code, argc, argv, strcmp()
  5. Date: Fri, 2 Feb 1996 23:16:14 +0100
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <9602022216.AA20125@dxmint.cern.ch>
  8. References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu>
  9. X-NNTP-Posting-Host: hpl3sn03.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11. X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
  12.  
  13. fcusack@tdx.org (frank.) writes:
  14.  
  15. >argv[1] is always guaranteed to exist. It is simply NULL if there were no
  16. >arguments.
  17.  
  18. It may be always guaranteed on your platform, but the C language doesn't
  19. provide such a guarantee.  The standard allows the situation when argc == 0,
  20. argv[0] == NULL and argv[1] doesn't exist at all.
  21.  
  22. ANSI classic 2.1.2.2:
  23.  
  24.     If they are defined, the parameters to the main function shall obey
  25.     the following constraints:
  26.  
  27.      * The value of argc shall be nonnegative.  
  28.  
  29.      * argv[argc] shall be a null pointer.  
  30.  
  31.      * If the value of argc is greater than zero, the array members
  32.        argv[0] through argv[argc-1] inclusive shall contain pointers to
  33.        strings, which are given implementation-defined values by the host
  34.        environment prior to program startup.  The intent is to supply to the
  35.        program information determined prior to program startup from elsewhere
  36.        in the hosted environment.  If the host environment is not capable of
  37.        supplying strings with letters in both upper-case and lower-case, the
  38.        implementation shall ensure that the strings are received in
  39.        lower-case.
  40.  
  41.      * If the value of argc is greater than zero, the string pointed to by
  42.        argv[0] represents the program name ;argv[0][0] shall be the null
  43.        character if the program name is not available from the host
  44.        environment.  If the value of argc is greater than one, the strings
  45.        pointed to by argv[1] through argv[argc-1] represent the program
  46.        parameters .
  47.  
  48.      * The parameters argc and argv and the strings pointed to by the argv
  49.        array shall be modifiable by the program, and retain their last-stored
  50.        values between program startup and program termination.
  51.  
  52. Dan
  53. -- 
  54. Dan Pop
  55. CERN, CN Division
  56. Email: danpop@mail.cern.ch 
  57. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  58.